package cn.wj.school.app.enums;

import cn.wj.school.app.net.client.context.Session;
import cn.wj.school.common.dto.BaseMsg;
import io.netty.channel.Channel;

/**
 * @Author: yueding
 * @Description:
 * @Date: Created in 16:29 2018/12/28
 * @Modified By: yueding Copyright(c) cai-inc.com
 */
public enum SessionFactory {
    INSTANCE;

    /** 通信会话 */
    private Session session;

    public void registerSession(Channel channel) {
        this.session = new Session(channel);
    }

    /**
     * 发送请求
     * 
     * @param request
     */
    public void sendServerRequest(BaseMsg request) {
        this.session.sendMessage(request);
    }

    /**
     * 是否已连上服务器
     * 
     * @return
     */
    public boolean isConnectedSever() {
        return this.session != null;
    }

    /**
     * 移除session
     */
    public void removeSession() {
        this.session = null;
    }


}
